-- p.60 #3
mean, mean2 :: (Fractional n) => [n] -> n

mean (n:ns) = sum / (fromIntegral len)
              where sum = foldl (+)  0 (n:ns)
                    len = length (n:ns)

mean2 (n:ns) = walk (n:ns) 0 0
               where walk (n:ns) sum count = walk ns (sum + n) (count + 1)
                     walk []     sum count = sum / count
